home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / morrison / dir.m < prev    next >
Text File  |  1988-07-27  |  23KB  |  1,079 lines

  1. ;**---------------------------------------------------------------------------
  2. ;**
  3. ;**                                   DIR Macro
  4. ;**
  5. ;**---------------------------------------------------------------------------
  6. ;**
  7. ;**        This macro is designed to operate simular to the menus seen in
  8. ;**        the popular NORTON COMMANDER program.  You can go UP or DOWN the
  9. ;**        tree structure on the disk by moving the cursor over the proper
  10. ;**        <DIR> entry in the directory and hitting the <Enter> key.
  11. ;**
  12. ;**        If the <Enter> key is hit and a file (instead of a directory
  13. ;**        <DIR> entry) is highlighted then this file will be loaded into
  14. ;**        BRIEF and be ready for editing.  
  15. ;**
  16. ;**        The <Ins> or <Space> key will TOGGLE the file marker for the
  17. ;**        file that is currently highlighted.  <DIR> files MAY NOT BE
  18. ;**        marked as they can not be edited.  After having marked one or
  19. ;**        more (as many as you like) you can then have ALL of the MARKED
  20. ;**        files loaded into BRIEF by hitting the <Alt-L> key.
  21. ;**
  22. ;**        If you do NOT wish to edit any files, simply hit the <Esc> key
  23. ;**        and you will be back editing the file that you started with.
  24. ;**
  25. ;**        The <Home>, <End>, <Up>, <Down>, <PgUp>, and <PgDn> keys are
  26. ;**        used to move you around within the directory.
  27. ;**
  28. ;**        Written BY:  Robert H. Morrison, 1 July 1988
  29. ;**                     Karlsruhe, West Germany
  30. ;**
  31. ;**        Last Update: 6 July 1988
  32. ;**
  33. ;*****************************************************************************
  34.  
  35. #define        LINE        3
  36. #define        SYSTEM        1
  37.  
  38. #define        UP_DIR        ".."
  39. #define        DOWN_DIR      ".\\"
  40.  
  41. #define        SELECT        1
  42. #define        UNSELECT    2
  43.  
  44. #define        ALT_KEY        8
  45.  
  46. #include    "dialog.h"
  47.  
  48.  
  49. (macro     _init
  50.     (
  51.         (int    mark_typ
  52.                 updir
  53.                 alt_done
  54.                 rows
  55.                 cols
  56.         )
  57.  
  58.         (string    new_file
  59.                 bhelp
  60.                 bdirfile
  61.                 bdirpgm
  62.                 bdiropt
  63.                 bdirtxt
  64.                 old_opt
  65.                 select
  66.                 unselect
  67.                 alt_search
  68.                 bdir
  69.         )
  70.  
  71.         (global    new_file
  72.                 bhelp
  73.                 bdirfile
  74.                 bdirpgm
  75.                 bdiropt
  76.                 bdirtxt
  77.                 old_opt
  78.                 select
  79.                 unselect
  80.                 alt_search
  81.                 alt_done
  82.                 bdir
  83.                 mark_typ
  84.                 updir
  85.                 rows
  86.                 cols
  87.         )
  88.  
  89.         (= alt_search "\<■\|  ")
  90.         (= alt_done FALSE)
  91.         (= bhelp (lower (inq_environment "BHELP")))
  92.         (if (!= bhelp "")
  93.             (+= bhelp "\\")
  94.         )
  95.         (= bdiropt "F")
  96.         (= bdirfile (+ bhelp "temp.dir"))
  97.         (= bdirpgm (+ bhelp "bmakedir.exe"))
  98.         (= bdirtxt (+ bhelp "bmakedir.txt"))
  99.         (= bdir (+ bdirpgm (+ (+ " \-" bdiropt) (+ " \>&" bdirfile))))
  100.         (inq_screen_size rows cols)
  101.         (-= rows 10)
  102.         (-= cols 42)
  103.         (/= cols 2)
  104.     )
  105. )
  106.  
  107.  
  108. (macro    dir
  109.     (
  110.         (extern    to_bottom
  111.                 display_file_name
  112.         )
  113.  
  114.         (int    dir_buffer    
  115.                 old_buffer
  116.                 dir_window    
  117.                 old_window
  118.                 end_line
  119.                 line
  120.         )
  121.  
  122.         (string    temp        
  123.                 this_line
  124.                 current_dir
  125.                 current_drive
  126.                 answer
  127.         )
  128.  
  129.         (global    end_line
  130.                 this_line
  131.                 line
  132.                 old_buffer
  133.                 dir_buffer
  134.                 current_dir
  135.                 current_drive
  136.                 answer
  137.         )
  138.  
  139.  
  140.         (= new_file "")
  141.         (message "Reading disk directory...")
  142.         (dos bdir)
  143.         (= old_buffer (inq_buffer))
  144.         (= dir_buffer (create_buffer "DIR Ver 1.00" bdirtxt SYSTEM))
  145.         (create_window cols (+ rows 4) (+ cols 42) 3 "Ins - + Enter F1 F2 F4 F7 F8 F9 F10 Esc")
  146.         (attach_buffer dir_buffer)
  147.         (set_buffer dir_buffer)
  148.         (getwd NULL current_dir)
  149.         (= current_dir (upper current_dir))
  150.         (= current_drive (substr current_dir 1 1))
  151.         (top_of_buffer)
  152.         (read_file bdirfile)
  153.         (up)
  154.         (inq_position end_line NULL)
  155.         (top_of_buffer)
  156.  
  157.         (keyboard_push)
  158.         (assign_to_key "<Space>" "no_beep")
  159.         (assign_to_key "<Enter>" "select_dir")
  160.         (assign_to_key "<Home>" "top_of_dir")
  161.         (assign_to_key "<End>" "end_of_dir")
  162.         (assign_to_key "<Up>" "up_dir")
  163.         (assign_to_key "<Down>" "down_dir")
  164.         (assign_to_key "<PgUp>" "pgup_dir")
  165.         (assign_to_key "<PgDn>" "pgdown_dir")
  166.         (assign_to_key "<Ins>" "mark_dir")
  167.         (assign_to_key "<Ctrl-PgUp>" "up_1_dir")
  168.         (assign_to_key "<F1>" "help_dir")
  169.         (assign_to_key "<F2>" "change_drive")
  170.         (assign_to_key "<F4>" "load_marked")
  171.         (assign_to_key "<F7>" "make_dir")
  172.         (assign_to_key "<F8>" "delete_file")
  173.         (assign_to_key "<F9>" "set_mode")
  174.         (assign_to_key "<F10>" "_exit")
  175.         (assign_to_key "<Esc>" "_exit")
  176.         (assign_to_key "<Ctrl-\\>" "root_dir")
  177.         (assign_to_key "<\\>" "root_dir")
  178.         (assign_to_key "<Ctrl-R>" "read_dir")
  179.         (assign_to_key "<Keypad-minus>" "unselect_marks")
  180.         (assign_to_key "<Keypad-plus>" "select_marks")
  181.         (assign_to_key "<Alt-a>" "NC_alt_search a")
  182.         (assign_to_key "<Alt-b>" "NC_alt_search b")
  183.         (assign_to_key "<Alt-c>" "NC_alt_search c")
  184.         (assign_to_key "<Alt-d>" "NC_alt_search d")
  185.         (assign_to_key "<Alt-e>" "NC_alt_search e")
  186.         (assign_to_key "<Alt-f>" "NC_alt_search f")
  187.         (assign_to_key "<Alt-g>" "NC_alt_search g")
  188.         (assign_to_key "<Alt-h>" "NC_alt_search h")
  189.         (assign_to_key "<Alt-i>" "NC_alt_search i")
  190.         (assign_to_key "<Alt-j>" "NC_alt_search j")
  191.         (assign_to_key "<Alt-k>" "NC_alt_search k")
  192.         (assign_to_key "<Alt-l>" "NC_alt_search l")
  193.         (assign_to_key "<Alt-m>" "NC_alt_search m")
  194.         (assign_to_key "<Alt-n>" "NC_alt_search n")
  195.         (assign_to_key "<Alt-o>" "NC_alt_search o")
  196.         (assign_to_key "<Alt-p>" "NC_alt_search p")
  197.         (assign_to_key "<Alt-q>" "NC_alt_search q")
  198.         (assign_to_key "<Alt-r>" "NC_alt_search r")
  199.         (assign_to_key "<Alt-s>" "NC_alt_search s")
  200.         (assign_to_key "<Alt-t>" "NC_alt_search t")
  201.         (assign_to_key "<Alt-u>" "NC_alt_search u")
  202.         (assign_to_key "<Alt-v>" "NC_alt_search v")
  203.         (assign_to_key "<Alt-w>" "NC_alt_search w")
  204.         (assign_to_key "<Alt-x>" "NC_alt_search x")
  205.         (assign_to_key "<Alt-y>" "NC_alt_search y")
  206.         (assign_to_key "<Alt-z>" "NC_alt_search z")
  207.         (assign_to_key "<Alt-_>" "NC_alt_search _")
  208.         (assign_to_key "<Alt-0>" "NC_alt_search 0")
  209.         (assign_to_key "<Alt-1>" "NC_alt_search 1")
  210.         (assign_to_key "<Alt-2>" "NC_alt_search 2")
  211.         (assign_to_key "<Alt-3>" "NC_alt_search 3")
  212.         (assign_to_key "<Alt-4>" "NC_alt_search 4")
  213.         (assign_to_key "<Alt-5>" "NC_alt_search 5")
  214.         (assign_to_key "<Alt-6>" "NC_alt_search 6")
  215.         (assign_to_key "<Alt-7>" "NC_alt_search 7")
  216.         (assign_to_key "<Alt-8>" "NC_alt_search 8")
  217.         (assign_to_key "<Alt-9>" "NC_alt_search 9")
  218.  
  219.         (drop_anchor LINE)
  220.         (message "%s" current_dir)
  221.         (refresh)
  222.  
  223.         (process)
  224.  
  225.         (keyboard_pop)
  226.         (delete_window)
  227.         (if (!= new_file "")
  228.             (
  229.                 (if (!= new_file "Load Multiple Files")
  230.                     (
  231.                         (message "Loading \"%s\" for editing..." new_file)
  232.                         (edit_file new_file)
  233.                         (= old_buffer (inq_buffer))
  234.                     )
  235.                 ;else
  236.                     (
  237.                         (top_of_buffer)
  238.                         (while (search_fwd "<\\c■")
  239.                             (
  240.                                 (= this_line (read))
  241.                                 (down)
  242.                                 (= new_file (trim (substr this_line 3 8)))
  243.                                 (+= new_file (+ "." (trim (substr this_line 12 3))))
  244.                                 (message "Loading \"%s\" for editing..." new_file)
  245.                                 (edit_file new_file)
  246.                                 (= old_buffer (inq_buffer))
  247.                                 (set_buffer dir_buffer)
  248.                             )
  249.                         )
  250.                     )
  251.                 )
  252.             )
  253.         )
  254.         (set_buffer old_buffer)
  255.         (delete_buffer dir_buffer)
  256.         (display_file_name)
  257.     )
  258. )
  259.  
  260.  
  261. (macro no_beep
  262.     (
  263.         (return)
  264.     )
  265. )
  266.  
  267.  
  268. (macro end_NC_alt
  269.     (
  270.         (get_parm 0 alt_search)
  271.         (exit)
  272.     )
  273. )
  274.  
  275.  
  276. (macro NC_alt_search
  277.     (
  278.         (extern _do_beep)
  279.  
  280.         (int    alt_line)
  281.  
  282.         (string alt_char)
  283.  
  284.         (keyboard_push)
  285.         (assign_to_key "<Enter>" "end_NC_alt <Enter>")
  286.         (assign_to_key "<Home>" "end_NC_alt <Home>")
  287.         (assign_to_key "<End>" "end_NC_alt <End>")
  288.         (assign_to_key "<Up>" "end_NC_alt <Up>")
  289.         (assign_to_key "<Down>" "end_NC_alt <Down>")
  290.         (assign_to_key "<PgUp>" "end_NC_alt <PgUp>")
  291.         (assign_to_key "<PgDn>" "end_NC_alt <PgDn>")
  292.         (assign_to_key "<Ins>" "end_NC_alt <Ins>")
  293.         (assign_to_key "<Ctrl-PgUp>" "end_NC_alt <Ctrl-PgUp>")
  294.         (assign_to_key "<F1>" "end_NC_alt <F1>")
  295.         (assign_to_key "<F2>" "end_NC_alt <F2>")
  296.         (assign_to_key "<F4>" "end_NC_alt <F4>")
  297.         (assign_to_key "<F7>" "end_NC_alt <F7>")
  298.         (assign_to_key "<F8>" "end_NC_alt <F8>")
  299.         (assign_to_key "<F9>" "end_NC_alt <F9>")
  300.         (assign_to_key "<F10>" "end_NC_alt <F10>")
  301.         (assign_to_key "<Esc>" "end_NC_alt <Esc>")
  302.         (assign_to_key "<Ctrl-\\>" "end_NC_alt <Ctrl-\\>")
  303.         (assign_to_key "<\\>" "end_NC_alt <\\>")
  304.         (assign_to_key "<Ctrl-R>" "end_NC_alt <Ctrl-R>")
  305.         (assign_to_key "<Keypad-minus>" "end_NC_alt <Keypad-minus>")
  306.         (assign_to_key "<Keypad-plus>" "end_NC_alt <Keypad-plus>")
  307.         (assign_to_key "<Alt-a>" "NC_alt a")
  308.         (assign_to_key "<Alt-b>" "NC_alt b")
  309.         (assign_to_key "<Alt-c>" "NC_alt c")
  310.         (assign_to_key "<Alt-d>" "NC_alt d")
  311.         (assign_to_key "<Alt-e>" "NC_alt e")
  312.         (assign_to_key "<Alt-f>" "NC_alt f")
  313.         (assign_to_key "<Alt-g>" "NC_alt g")
  314.         (assign_to_key "<Alt-h>" "NC_alt h")
  315.         (assign_to_key "<Alt-i>" "NC_alt i")
  316.         (assign_to_key "<Alt-j>" "NC_alt j")
  317.         (assign_to_key "<Alt-k>" "NC_alt k")
  318.         (assign_to_key "<Alt-l>" "NC_alt l")
  319.         (assign_to_key "<Alt-m>" "NC_alt m")
  320.         (assign_to_key "<Alt-n>" "NC_alt n")
  321.         (assign_to_key "<Alt-o>" "NC_alt o")
  322.         (assign_to_key "<Alt-p>" "NC_alt p")
  323.         (assign_to_key "<Alt-q>" "NC_alt q")
  324.         (assign_to_key "<Alt-r>" "NC_alt r")
  325.         (assign_to_key "<Alt-s>" "NC_alt s")
  326.         (assign_to_key "<Alt-t>" "NC_alt t")
  327.         (assign_to_key "<Alt-u>" "NC_alt u")
  328.         (assign_to_key "<Alt-v>" "NC_alt v")
  329.         (assign_to_key "<Alt-w>" "NC_alt w")
  330.         (assign_to_key "<Alt-x>" "NC_alt x")
  331.         (assign_to_key "<Alt-y>" "NC_alt y")
  332.         (assign_to_key "<Alt-z>" "NC_alt z")
  333.         (assign_to_key "<Alt-_>" "NC_alt _")
  334.         (assign_to_key "<Alt-0>" "NC_alt 0")
  335.         (assign_to_key "<Alt-1>" "NC_alt 1")
  336.         (assign_to_key "<Alt-2>" "NC_alt 2")
  337.         (assign_to_key "<Alt-3>" "NC_alt 3")
  338.         (assign_to_key "<Alt-4>" "NC_alt 4")
  339.         (assign_to_key "<Alt-5>" "NC_alt 5")
  340.         (assign_to_key "<Alt-6>" "NC_alt 6")
  341.         (assign_to_key "<Alt-7>" "NC_alt 7")
  342.         (assign_to_key "<Alt-8>" "NC_alt 8")
  343.         (assign_to_key "<Alt-9>" "NC_alt 9")
  344.  
  345.         (unregister_macro 3 "_do_beep")
  346.         (register_macro 3 "end_NC_alt")
  347.  
  348.         (= alt_done FALSE)
  349.         (inq_position line NULL)
  350.         (top_of_buffer)
  351.         (get_parm 0 alt_char)
  352.         (NC_alt alt_char)
  353.  
  354.         (process)
  355.  
  356.         (keyboard_pop)
  357.         (register_macro 3 "_do_beep")
  358.         (unregister_macro 3 "end_NC_alt")
  359.  
  360.         (push_back (key_to_int alt_search))
  361.         (= alt_search "\<■\|  ")
  362.     )
  363. )
  364.  
  365.  
  366. (macro NC_alt
  367.     (
  368.         (string alt_char)
  369.  
  370.         (if (! alt_done)
  371.             (
  372.                 (get_parm 0 alt_char "" 1)
  373.  
  374.                 (raise_anchor)
  375.  
  376.                 (+= alt_search alt_char)
  377.  
  378.                 (message "Searching DIR for \"%s\".\*" (substr alt_search 6))
  379.  
  380.                 (if (search_fwd alt_search TRUE FALSE FALSE)
  381.                     (inq_position line NULL)
  382.                 ;else
  383.                     (= alt_done TRUE)
  384.                 )
  385.  
  386.                 (message "%s" current_dir)
  387.  
  388.                 (move_abs line 1)
  389.                 (drop_anchor LINE)
  390.                 (refresh)
  391.             )
  392.         )
  393.  
  394.         (while (! (inq_kbd_char))
  395.             (
  396.                 (if (! (& (inq_kbd_flags) ALT_KEY))
  397.                     (
  398.                         (execute_macro "end_NC_alt <Space>")
  399.                         (break)
  400.                     )
  401.                 )
  402.             )
  403.         )
  404.  
  405.     )
  406. )
  407.  
  408.  
  409. (macro    change_drive
  410.     (
  411.         (= current_drive "?")
  412.         (= new_file "Change Drive")
  413.         (while (&& (!= current_drive "") (|| (< current_drive "A") (> current_drive "Z")))
  414.             (
  415.                 (if (!= current_drive "?")
  416.                     (beep)
  417.                 )
  418.                 (= current_drive "")
  419.                 (get_parm NULL current_drive "Input New Drive Letter? " 1)
  420.                 (if (== current_drive "?")
  421.                     (beep)
  422.                 )
  423.                 (= current_drive (upper current_drive))
  424.             )
  425.         )
  426.         (if (&& (>= current_drive "A") (<= current_drive "Z"))
  427.             (select_dir)
  428.         ;else
  429.             (
  430.                 (message "%s" current_dir)
  431.                 (= current_drive (substr current_dir 1 1))
  432.                 (= new_file "")
  433.             )
  434.         )
  435.     )
  436. )
  437.  
  438.  
  439. (macro    make_dir
  440.     (
  441.         (string    subdir)
  442.  
  443.         (get_parm NULL subdir "Name of SUB-DIR? " 12)
  444.         (if (!= subdir "")
  445.             (
  446.                 (= new_file "Change Drive")
  447.                 (= subdir (upper subdir))
  448.                 (message "Creating SUB-DIR \"%s\"..." subdir)
  449.                 (if (dos (+ (+ "md " subdir) "\>\&tempmdir.err"))
  450.                     (error "Unable to create %s SUB-DIR." (+ DOWN_DIR subdir))
  451.                 ;else
  452.                     (
  453.                         (del "tempmdir.err")
  454.                         (select_dir)
  455.                     )
  456.                 )
  457.             )
  458.         ;else
  459.             (message "%s" current_dir)
  460.         )
  461.     )
  462. )
  463.  
  464.  
  465. (macro    help_dir
  466.     (
  467.         (extern display_help)
  468.  
  469.         (display_help "dir")
  470.         (message "%s" current_dir)
  471.         (keyboard_flush)
  472.     )
  473. )
  474.  
  475.  
  476. (macro    read_dir
  477.     (
  478.         (= new_file "Change Drive")
  479.         (select_dir)
  480.     )
  481. )
  482.  
  483.  
  484. (macro    up_1_dir
  485.     (
  486.         (if (> (strlen current_dir) 3)
  487.             (
  488.                 (= new_file "Change Drive UP")
  489.                 (select_dir)
  490.             )
  491.         ;else
  492.             (beep)
  493.         )
  494.     )
  495. )
  496.  
  497.  
  498. (macro    root_dir
  499.     (
  500.         (if (> (strlen current_dir) 3)
  501.             (
  502.                 (= new_file "Change Drive")
  503.                 (cd "\\")
  504.                 (select_dir)
  505.             )
  506.         ;else
  507.             (beep)
  508.         )
  509.     )
  510. )
  511.  
  512.  
  513. (macro    delete_file
  514.     (
  515.         (inq_position line NULL)
  516.         (raise_anchor)
  517.         (top_of_buffer)
  518.         (if (search_fwd "<\\c■")
  519.             (
  520.                 (= answer "?")
  521.                 (while (&& (!= (upper answer) "Y") (!= (upper answer) "N"))
  522.                     (
  523.                         (if (!= answer "?")
  524.                             (beep)
  525.                         )
  526.                         (= answer "")
  527.                         (get_parm NULL answer "Delete ALL MARKED files \[YyNn\]? " 1)
  528.                         (if (== answer "")
  529.                             (= answer "N")
  530.                         ;else
  531.                             (if (== answer "?")
  532.                                 (beep)
  533.                             )
  534.                         )
  535.                     )
  536.                 )
  537.                 (if (== (upper answer) "Y")
  538.                     (
  539.                         (top_of_buffer)
  540.                         (while (search_fwd "<\\c■")
  541.                             (
  542.                                 (= this_line (read))
  543.                                 (beginning_of_line)
  544.                                 (down)
  545.                                 (= new_file (trim (substr this_line 3 8)))
  546.                                 (if (search_string "DIR" this_line NULL 0)
  547.                                     (
  548.                                         (if (!= (substr new_file 1 2) "..")
  549.                                             (
  550.                                                 (if (!= (substr this_line 12 1) " ")
  551.                                                     (+= new_file (+ "." (trim (substr this_line 12 3))))
  552.                                                 )
  553.                                                 (error "%s" this_line)
  554.                                                 (message "Deleting \"%s\" Directory..." new_file)
  555.                                                 (dos (+ "rd " (+ new_file " \>&temp.err")))
  556.                                                 (del "temp.err")
  557.                                             )
  558.                                         )
  559.                                     )
  560.                                 ;else
  561.                                     (
  562.                                         (+= new_file (+ "." (trim (substr this_line 12 3))))
  563.                                         (message "Deleting \"%s\" from DISK..." new_file)
  564.                                         (if (<= (del new_file) 0)
  565.                                             (
  566.                                                 (beep)
  567.                                                 (error "Unable to delete \"%s\" - Hit ANY key " new_file)
  568.                                                 (while (! (inq_kbd_char)))
  569.                                                 (read_char)
  570.                                             )
  571.                                         )
  572.                                     )
  573.                                 )
  574.                             )
  575.                         )
  576.                     )
  577.                     ;else
  578.                     (
  579.                         (move_abs line 1)
  580.                           (drop_anchor LINE)
  581.                         (message "%s" current_dir)
  582.                         (return)
  583.                     )
  584.                 )
  585.             )
  586.         ;else
  587.             (
  588.                 (move_abs line 1)
  589.                   (drop_anchor LINE)
  590.                 (= this_line (read))
  591.                 (beginning_of_line)
  592.                 (= answer "?")
  593.                 (while (&& (!= (upper answer) "Y") (!= (upper answer) "N"))
  594.                     (
  595.                         (if (!= answer "?")
  596.                             (beep)
  597.                         )
  598.                         (= answer "")
  599.                         (get_parm NULL answer "Delete HIGHLIGHTED FILE from DISK \[YyNn\]? " 1)
  600.                         (if (== answer "")
  601.                             (= answer "N")
  602.                         ;else
  603.                             (if (== answer "?")
  604.                                 (beep)
  605.                             )
  606.                         )
  607.                     )
  608.                 )
  609.                 (if (== (upper answer) "Y")
  610.                     (
  611.                         (= new_file (trim (substr this_line 3 8)))
  612.                         (if (search_string "DIR" this_line NULL 0)
  613.                             (
  614.                                 (if (!= (substr new_file 1 2) "..")
  615.                                     (
  616.                                         (if (!= (substr this_line 12 1)    " ")
  617.                                             (+= new_file (+ "." (trim (substr this_line 12 3))))
  618.                                         )
  619.                                         (message "Deleting \"%s\" Directory..." new_file)
  620.                                           (dos (+ "rd " (+ new_file " \>&tempddir.err")))
  621.                                         (del "tempddir.err")
  622.                                     )
  623.                                 )
  624.                             )
  625.                         ;else
  626.                             (
  627.                                 (+= new_file (+ "." (trim (substr this_line 12 3))))
  628.                                 (message "Deleting \"%s\" from DISK..." new_file)
  629.                                 (if (<= (del new_file) 0)
  630.                                     (
  631.                                         (beep)
  632.                                         (error "Unable to delete \"%s\" - Hit ANY key " new_file)
  633.                                         (while (! (inq_kbd_char)))
  634.                                         (read_char)
  635.                                     )
  636.                                 )
  637.                             )
  638.                         )
  639.                     )
  640.                     ;else
  641.                     (
  642.                         (message "%s" current_dir)
  643.                         (return)
  644.                     )
  645.                 )
  646.             )
  647.         )
  648.         (read_dir)
  649.     )
  650. )
  651.  
  652.  
  653. (macro    load_marked
  654.     (
  655.         (inq_position line NULL)
  656.         (= this_line (read 16))
  657.         (raise_anchor)
  658.         (top_of_buffer)
  659.         (if (search_fwd "<\\c■")
  660.             (= new_file "Load Multiple Files")
  661.         ;else
  662.             (
  663.                 (if (== "" (substr this_line 16 1))
  664.                     (
  665.                         (= new_file "")
  666.                         (beep)
  667.                         (error "DIRECTORIES may NOT be edited.  Hit ANY key...")
  668.                         (while (! (inq_kbd_char)))
  669.                         (read_char)
  670.                         (message "%s" current_dir)
  671.                         (move_abs line 1)
  672.                         (drop_anchor LINE)
  673.                         (return)
  674.                     )
  675.                 ;else
  676.                     (
  677.                         (= new_file (trim (substr this_line 3 8)))
  678.                         (+= new_file (+ "." (trim (substr this_line 12 3))))
  679.                     )
  680.                 )
  681.             )
  682.         )
  683.         (exit)
  684.     )
  685. )
  686.  
  687.  
  688. (macro    top_of_dir
  689.     (
  690.         (raise_anchor)
  691.         (top_of_buffer)
  692.         (drop_anchor LINE)
  693.     )
  694. )
  695.  
  696.  
  697. (macro    end_of_dir
  698.     (
  699.         (raise_anchor)
  700.         (move_abs end_line 1)
  701.         (beginning_of_line)
  702.         (to_bottom)
  703.         (drop_anchor LINE)
  704.     )
  705. )
  706.  
  707.  
  708. (macro    pgup_dir
  709.     (
  710.         (extern    screen_down)
  711.         (int    count)
  712.  
  713.         (raise_anchor)
  714.         (inq_position line NULL)
  715.         (= count rows)
  716.         (-= line count)
  717.         (if (> line    1)
  718.             (while count
  719.                 (
  720.                     (screen_down)
  721.                     (-- count)
  722.                 )
  723.             )
  724.         ;else
  725.             (
  726.                 (top_of_dir)
  727.                 (return)
  728.             )
  729.         )
  730.         (move_abs line 1)
  731.         (drop_anchor LINE)
  732.     )
  733. )
  734.  
  735.  
  736. (macro    pgdown_dir
  737.     (
  738.         (extern    screen_up)
  739.         (int    count)
  740.  
  741.         (raise_anchor)
  742.         (inq_position line NULL)
  743.         (= count rows)
  744.         (+= line count)
  745.         (if (<= line end_line)
  746.             (while count
  747.                 (
  748.                     (screen_up)
  749.                     (-- count)
  750.                 )
  751.             )
  752.         ;else
  753.             (
  754.                 (end_of_dir)
  755.                 (return)
  756.             )
  757.         )
  758.         (move_abs line 1)
  759.         (drop_anchor LINE)
  760.     )
  761. )
  762.  
  763.  
  764. (macro    up_dir
  765.     (
  766.         (raise_anchor)
  767.         (up)
  768.         (drop_anchor LINE)
  769.     )
  770. )
  771.  
  772.  
  773. (macro    down_dir
  774.     (
  775.         (inq_position line NULL)
  776.         (if (!= line end_line)
  777.             (
  778.                 (raise_anchor)
  779.                 (down)
  780.                 (drop_anchor LINE)
  781.             )
  782.         )
  783.     )
  784. )
  785.  
  786.  
  787. (macro    mark_dir
  788.     (
  789.         (= this_line (read 16))
  790.  
  791.         (if    (!= (substr  this_line 16 1) "")
  792.             (
  793.                 (delete_char)
  794.                 (if (search_string "■" this_line NULL 0)
  795.                     (
  796.                         (insert " ")
  797.                     )
  798.                 ;else
  799.                     (
  800.                         (insert "■")
  801.                     )
  802.                 )
  803.                 (beginning_of_line)
  804.             )
  805.         )
  806.     )
  807. )
  808.  
  809.  
  810. (macro convert_select
  811.     (            
  812.         (int    index_sel)
  813.         (string    temp_char
  814.                 temp_sel
  815.         )
  816.  
  817.         (get_parm 0 select)
  818.         (= index_sel 1)
  819.  
  820.         (while (<= index_sel (strlen select))
  821.             (
  822.                 (= temp_char (substr select index_sel 1))
  823.                 (if (index "\@\+\{\}\-\<\%\>\$" temp_char)
  824.                     (+= temp_sel "\\")
  825.                 )
  826.                 (+= temp_sel temp_char)
  827.                 (++ index_sel)
  828.             )
  829.         )
  830.  
  831.         (if (strlen temp_sel)
  832.             (= temp_sel (+ (+ "■\|  " temp_sel) " @│"))
  833.         ;else
  834.             (= temp_sel "")
  835.         )
  836.  
  837.         (put_parm 0 temp_sel)
  838.     )
  839. )
  840.  
  841.  
  842. (macro select_action
  843.     (
  844.         (int    event_type
  845.                 line_no
  846.         )
  847.  
  848.         (string    button_text
  849.         )
  850.  
  851.         (get_parm 0 event_type)
  852.         (get_parm 1 line_no)
  853.         (get_parm 2 button_text)
  854.  
  855.         (switch event_type
  856.             DIALOG_ENTER_FIELD
  857.             (
  858.                 (= select "\*.\*")
  859.             )
  860.             DIALOG_EXIT_FIELD
  861.             (
  862.                 (= select button_text)
  863.                 (put_parm 0 DIALOG_F10)
  864.             )
  865.             DIALOG_ESCAPE
  866.             (
  867.                 (= select "")
  868.             )
  869.         )
  870.         (return TRUE)
  871.     )
  872. )
  873.  
  874.  
  875. (macro multiple_marks
  876.     (
  877.         (int    line_no
  878.         )
  879.  
  880.         (raise_anchor)
  881.         (if (== mark_typ SELECT)
  882.              (_process_dialog_box (+ cols 11) 10 (+ cols 28) 8 "Select" "" "select" NULL "select_action")
  883.         ;else
  884.              (_process_dialog_box (+ cols 11) 10 (+ cols 28) 8 "Unselect" "" "select" NULL "select_action")
  885.         )
  886.         (if (!= select "")
  887.             (
  888.                 (convert_select select)
  889.                 (get_parm 0 select)
  890.                 (message "Marking specified files...")
  891.                 (inq_position line NULL)
  892.                 (= line_no end_line)
  893.  
  894.                 (while line_no
  895.                     (
  896.                         (move_abs line_no 1)          
  897.                         (= this_line (read 16))
  898.                         (= new_file (trim (substr this_line 1 10)))
  899.                         (+= new_file (+ "." (trim (substr this_line 12 4))))
  900.                         (if (&& (search_string select new_file) (!= (substr this_line 16 1) ""))
  901.                             (
  902.                                 (delete_char)
  903.                                 (switch mark_typ
  904.                                     SELECT        (insert "■")
  905.                                     UNSELECT    (insert " ")
  906.                                 )
  907.                             )
  908.                         )
  909.                         (-- line_no)
  910.                     )
  911.                 )
  912.                 (= new_file "")
  913.                 (move_abs line 1)
  914.             )
  915.         )
  916.         (drop_anchor LINE)
  917.         (message "%s" current_dir)
  918.         (refresh)
  919.     )
  920. )
  921.  
  922.  
  923. (macro select_marks
  924.     (
  925.         (= mark_typ SELECT)
  926.         (multiple_marks)
  927.     )
  928. )
  929.  
  930.  
  931. (macro unselect_marks
  932.     (
  933.         (= mark_typ UNSELECT)
  934.         (multiple_marks)
  935.     )
  936. )
  937.  
  938.  
  939. (macro    select_dir
  940.     (
  941.         (string    old_dir)
  942.  
  943.         (= updir FALSE)
  944.         (= this_line (read 16))
  945.  
  946.         (if (|| (== "" (substr this_line 16 1)) (== (substr new_file 1 12) "Change Drive"))
  947.             (
  948.                 (if (|| (search_string ".." this_line NULL 0) (== (substr new_file 1 12) "Change Drive"))
  949.                     (
  950.                         (if (== new_file "Change Drive")
  951.                             (
  952.                                 (cd (+ current_drive ":"))
  953.                             )
  954.                         ;else
  955.                             (
  956.                                 (cd UP_DIR)
  957.                                 (= updir TRUE)
  958.                             )
  959.                         )
  960.                         (= new_file "")
  961.                     )
  962.                 ;else
  963.                     (
  964.                         (= new_file (trim (substr this_line 3 8)))
  965.                         (if (!= (substr this_line 12 1) " ")
  966.                             (+= new_file (+ "." (trim (substr this_line 12 3))))
  967.                         )
  968.                         (cd (+ DOWN_DIR new_file))
  969.                         (= new_file "")
  970.                     )
  971.                 )
  972.  
  973.                 (raise_anchor)
  974.                 (top_of_buffer)
  975.                 (drop_anchor LINE)
  976.                 (move_abs end_line 1)
  977.                 (delete_block)
  978.                 (top_of_buffer)
  979.                 (refresh)
  980.                 (message "Reading disk directory...")
  981.                 (dos bdir)
  982.                 (= old_dir current_dir)
  983.                 (getwd NULL current_dir)
  984.                 (= current_dir (upper current_dir))
  985.                 (= current_drive (substr current_dir 1 1))
  986.                 (read_file bdirfile)
  987.                 (up)
  988.                 (inq_position end_line NULL)
  989.                 (top_of_buffer)
  990.  
  991.                 (if updir
  992.                     (
  993.                         (= updir (strlen current_dir))
  994.                         (if (< updir (strlen old_dir))
  995.                             (
  996.                                 (int    dot)
  997.  
  998.                                 (if (> updir 3)
  999.                                     (++ updir)
  1000.                                 )
  1001.                                 (++ updir)
  1002.                                 (= select (upper (substr old_dir updir)))
  1003.                                 (= dot (index select "."))
  1004.                                 (if dot
  1005.                                      (= select (+ (+ (substr select 1 (- dot 1)) " \+") (substr select (+ dot 1)) ))
  1006.                                 )
  1007.                                 (search_fwd select)
  1008.                                 (beginning_of_line)
  1009.                             )
  1010.                         )
  1011.                         (= updir FALSE)
  1012.                     )
  1013.                 )
  1014.  
  1015.                 (drop_anchor LINE)
  1016.                 (message "%s" current_dir)
  1017.                 (refresh)
  1018.             )
  1019.         ;else
  1020.             (
  1021.                 (= new_file (trim (substr this_line 3 8)))
  1022.                 (+= new_file (+ "." (trim (substr this_line 12 3))))
  1023.                 (exit)
  1024.             )
  1025.         )
  1026.     )
  1027. )
  1028.  
  1029.  
  1030. (macro set_mode
  1031.     (
  1032.         (= old_opt bdiropt)
  1033.         (push_back (key_to_int bdiropt))
  1034.          (_process_dialog_box (- cols 3) 10 (+ cols 44) 8 "Sort DIR by" "" "setmode" NULL "mode_action")
  1035.         (if (!= old_opt bdiropt)
  1036.             (
  1037.                 (= bdiropt old_opt)
  1038.                 (= bdir (+ bdirpgm (+ (+ " \-" bdiropt) (+ " \>&" bdirfile))))
  1039.                 (read_dir)
  1040.             )
  1041.         ;else
  1042.             (message "%s" current_dir)
  1043.         )
  1044.     )
  1045. )
  1046.  
  1047.  
  1048. (macro mode_action
  1049.     (
  1050.         (int    event_type
  1051.                 line_no
  1052.         )
  1053.  
  1054.         (string    button_text
  1055.         )
  1056.  
  1057.         (get_parm 0 event_type)
  1058.         (get_parm 1 line_no)
  1059.         (get_parm 2 button_text)
  1060.  
  1061.         (switch event_type
  1062.             DIALOG_ENTER_LIST
  1063.             (
  1064.                 (= old_opt (substr button_text 1 1))
  1065.             )
  1066.             DIALOG_ALTER_LIST
  1067.             (
  1068.                 (= old_opt (substr button_text 1 1))
  1069.                 (put_parm 0 DIALOG_F10)
  1070.             )
  1071.             DIALOG_ESCAPE
  1072.             (
  1073.                 (= old_opt bdiropt)
  1074.             )
  1075.         )
  1076.         (return TRUE)
  1077.     )
  1078. )
  1079.